/**
 * MP Software.
 */
package controllers;

import models.Client;

/**
 * @author Jeremiah John M. Macariola
 *
 */
public class Employees extends CRUD {

    public static void list(Long clientId) {
        Client client = getClient(clientId);

        request.args.put("where", "client.id = " + client.id);
        session.put("clientId", client.id);
        session.put("clientName", client.name);

        parent();
    }

    private static Client getClient(Long clientId) {
        Client client = null;

        try {
            client = Client.findById(clientId);
        } catch (IllegalArgumentException iae) {
            clientId = Long.valueOf(session.get("clientId"));
            client = Client.findById(clientId);
        }
        return client;
    }

    public static void create() throws Exception {
        params.put("object.client.id", session.get("clientId"));
        parent();
    }

}
